package cn.ahut.test2;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class Product implements InteProduct,BeanNameAware,ApplicationContextAware,InitializingBean,DisposableBean{
	private String name;

	public Product(){
		System.out.println("第一步：实例化Bean-->构造函数被执行");
	}
	public void setName(String name) {
		System.out.println("第二步：封装属性-->执行set方法");
		this.name = name;
	}
	public void init(){
		System.out.println("第七步：bean正在被初始化。。。");
	}
	public void tearDown(){
		System.out.println("第十一 步：执行自定义销毁方法。。。");
	}
	
	public void add(){
		System.out.println("第九步：业务处理add方法被调用 ");
	}
	
	@Override
	public String toString() {
		return "Product [name=" + name + "]";
	}
	@Override
	public void setBeanName(String name) {
		System.out.println("第三步：注入类的名称"+name);
	}
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		System.out.println("第四步：注入ApplicationContext:-->"+applicationContext);
	}
	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("第六步：属性设置后执行");
	}
	@Override
	public void destroy() throws Exception {
		System.out.println("第十步：执行destroy销毁方法");
	}
	
	
}
